/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public boolean isPalindrome(ListNode head) {
        if (head == null) {
            return true;
        }
        List<Integer> list = new ArrayList();
        //ListNode cu = head;
        while (head != null) {
            list.add(head.val);
            head = head.next;
        }
        int front = 0;
        int last = list.size()-1;
        while (front < last) {
            if (! list.get(front).equals(list.get(last))) {
                return false;
            }
            front ++;
            last --;
        }
        return true;
    }
}
